package tds.study.payment.controller;

import tds.study.payment.pojo.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;

import tds.study.payment.entity.Payment;
import tds.study.payment.service.IPaymentService;
import tds.study.payment.pojo.query.PaymentQuery;
import tds.study.payment.pojo.vo.PaymentVo;
import tds.study.payment.pojo.dto.DeleteDto;
import tds.study.payment.pojo.dto.add.PaymentAddDto;
import tds.study.payment.pojo.dto.update.PaymentUpdateDto;
import tds.study.payment.pojo.vo.PageVo;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tds
 * @since 2021-11-09
 */
@RestController
@Api(value = "接口", tags = "接口")
@ApiSupport(order=1)
@RequestMapping("/payment/payment")
public class PaymentController {

   @Autowired
   private IPaymentService paymentService;

   @ApiOperation(value = "分页查询",notes="分页查询")
   @ApiOperationSupport(order = 1, author = "tds")
   @PostMapping("/queryPage")
   public Result<PageVo<PaymentVo>> queryPage(@ApiParam @RequestBody PaymentQuery query)  {
      return Result.success(paymentService.queryPage(query));
   }

   @ApiOperation(value = "新增",notes="新增")
   @ApiOperationSupport(order = 2, author = "tds")
   @PostMapping("/add")
   public Result add(@ApiParam @RequestBody @Validated PaymentAddDto addDto)  {
      paymentService.save(addDto);
      return Result.success();
   }

   @ApiOperation(value = "修改",notes="修改")
   @ApiOperationSupport(order = 3, author = "tds")
   @PostMapping("/update")
   public Result update(@ApiParam @RequestBody @Validated PaymentUpdateDto updateDto)  {
      paymentService.update(updateDto);
      return Result.success();
   }

   @ApiOperation(value = "删除多个",notes="删除多个")
   @ApiOperationSupport(order = 4, author = "tds")
   @PostMapping("/deleteBatch")
   public Result deleteBatch(@ApiParam @RequestBody @Validated DeleteDto deleteDto)  {
      paymentService.delete(deleteDto);
      return Result.success();
   }
}
